#ifndef _SURBASIC_BENCHMARK_BLOCK_H_
#define _SURBASIC_BENCHMARK_BLOCK_H_

#include <string>
#include <assert.h>
#include "surbasic/timestamp.h"

namespace SDBasic {

class BenchmarkBlock {
 public:
  // start when this object is created
  BenchmarkBlock(const std::string& name, size_t size);

  ~BenchmarkBlock();

  void Start();
  void Stop();

  void set_size(size_t size) { size_ = static_cast<double>(size); }
  void set_size_by_path(const std::string& path);

  // size in kB
  double size_kb() const {
    assert(stopped_);
    return size_ / 1024.0;
  }

  // Speed in kB/s
  double speed_kBs() const {
    assert(stopped_);
    return size_kb() / seconds();
  }

  double seconds() const {
    assert(stopped_);
    return seconds_;
  }

 private:
  std::string name_;
  double size_;
  time::Timestamp start_;
  double seconds_;
  bool stopped_;
};
}

#endif  // _SURBASIC_BENCHMARK_BLOCK_H_
